﻿USE [CodeDemonDb3]
GO
/****** Object:  StoredProcedure [dbo].[AddReviewLogEntry]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AddReviewLogEntry]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[AddReviewLogEntry]
GO
/****** Object:  StoredProcedure [dbo].[GetActiveUsers]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetActiveUsers]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetActiveUsers]
GO
/****** Object:  StoredProcedure [dbo].[GetParticipantReviewsByUserId]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetParticipantReviewsByUserId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetParticipantReviewsByUserId]
GO
/****** Object:  StoredProcedure [dbo].[GetProjectByProjectID]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjectByProjectID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjectByProjectID]
GO
/****** Object:  StoredProcedure [dbo].[GetProjectItemByItemID]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjectItemByItemID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjectItemByItemID]
GO
/****** Object:  StoredProcedure [dbo].[GetProjectItemsByArtifactID]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjectItemsByArtifactID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjectItemsByArtifactID]
GO
/****** Object:  StoredProcedure [dbo].[GetProjectPhaseArtifactsByPhaseId]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjectPhaseArtifactsByPhaseId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjectPhaseArtifactsByPhaseId]
GO
/****** Object:  StoredProcedure [dbo].[GetProjectPhasesByProjectID]    Script Date: 01/16/2009 09:21:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjectPhasesByProjectID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjectPhasesByProjectID]
GO
/****** Object:  StoredProcedure [dbo].[GetProjects]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetProjects]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetProjects]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewByReviewFileID]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewByReviewFileID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewByReviewFileID]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewCommentsByReviewFileIdAndLine]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewCommentsByReviewFileIdAndLine]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewCommentsByReviewFileIdAndLine]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewCommentsByReviewId]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewCommentsByReviewId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewCommentsByReviewId]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewFileCommentsByReviewFileId]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewFileCommentsByReviewFileId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewFileCommentsByReviewFileId]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewFilesByReviewFileId]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewFilesByReviewFileId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewFilesByReviewFileId]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewFilesByReviewId]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewFilesByReviewId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewFilesByReviewId]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewLogByReviewID]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewLogByReviewID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewLogByReviewID]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewParticipantsByReviewID]    Script Date: 01/16/2009 09:21:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewParticipantsByReviewID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewParticipantsByReviewID]
GO
/****** Object:  StoredProcedure [dbo].[GetReviewsById]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReviewsById]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetReviewsById]
GO
/****** Object:  StoredProcedure [dbo].[GetRevisionLatest]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetRevisionLatest]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetRevisionLatest]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByLogID]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNLogByLogID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNLogByLogID]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByRevision]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNLogByRevision]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNLogByRevision]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByRevisionAndRepository]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNLogByRevisionAndRepository]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNLogByRevisionAndRepository]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogEntriesByAuthorButNotDefectNumber]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNLogEntriesByAuthorButNotDefectNumber]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNLogEntriesByAuthorButNotDefectNumber]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogEntriesByDefectNumber]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNLogEntriesByDefectNumber]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNLogEntriesByDefectNumber]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositories]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNRepositories]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNRepositories]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositoryByID]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNRepositoryByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNRepositoryByID]
GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositoryByURL]    Script Date: 01/16/2009 09:21:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSVNRepositoryByURL]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSVNRepositoryByURL]
GO
/****** Object:  StoredProcedure [dbo].[GetUserByEmail]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetUserByEmail]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetUserByEmail]
GO
/****** Object:  StoredProcedure [dbo].[GetUserByUserID]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetUserByUserID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetUserByUserID]
GO
/****** Object:  StoredProcedure [dbo].[GetUserSessionByUserID]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetUserSessionByUserID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetUserSessionByUserID]
GO
/****** Object:  StoredProcedure [dbo].[InsertReviewParticipant]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertReviewParticipant]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InsertReviewParticipant]
GO
/****** Object:  StoredProcedure [dbo].[InsertReviewUserSessionVar]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertReviewUserSessionVar]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InsertReviewUserSessionVar]
GO
/****** Object:  StoredProcedure [dbo].[InsertSVNLog]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertSVNLog]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InsertSVNLog]
GO
/****** Object:  StoredProcedure [dbo].[InsertSVNLogRevisionReview]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertSVNLogRevisionReview]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InsertSVNLogRevisionReview]
GO
/****** Object:  StoredProcedure [dbo].[InsertUser]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertUser]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InsertUser]
GO
/****** Object:  StoredProcedure [dbo].[UpdateProjectItem]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateProjectItem]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateProjectItem]
GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewDetailsByReviewID]    Script Date: 01/16/2009 09:21:30 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateReviewDetailsByReviewID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateReviewDetailsByReviewID]
GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewFileHideByReviewFileId]    Script Date: 01/16/2009 09:21:31 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateReviewFileHideByReviewFileId]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateReviewFileHideByReviewFileId]
GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewParticipantStatus]    Script Date: 01/16/2009 09:21:31 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateReviewParticipantStatus]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateReviewParticipantStatus]
GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewParticipantVisit]    Script Date: 01/16/2009 09:21:31 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateReviewParticipantVisit]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateReviewParticipantVisit]
GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewStatusByReviewID]    Script Date: 01/16/2009 09:21:31 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateReviewStatusByReviewID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateReviewStatusByReviewID]

/****** Object:  StoredProcedure [dbo].[AddReviewLogEntry]    Script Date: 01/16/2009 09:25:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[AddReviewLogEntry] 
	-- Add the parameters for the stored procedure here
	@reviewID int, 
	@logMessage VARCHAR(255),
	@logTimeStamp DATETIME,
	@reviewUserID int,
	@reviewFileID int = NULL
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO ReviewLog (reviewID, logMessage, logTimeStamp, reviewUserID, reviewFileID )
	VALUES( @reviewID, @logMessage, @logTimeStamp, @reviewUserID, @reviewFileID )
END

GO
/****** Object:  StoredProcedure [dbo].[GetActiveUsers]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetActiveUsers] 
	-- Add the parameters for the stored procedure here
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * from Users
	where disableUser = 0
END




GO
/****** Object:  StoredProcedure [dbo].[GetParticipantReviewsByUserId]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetParticipantReviewsByUserId] 
	@reviewUserId int
AS
BEGIN
	SET NOCOUNT ON;

	SELECT r.* from Reviews r
	INNER JOIN ReviewParticipants rp ON r.reviewID = rp.ReviewID
	INNER JOIN ReviewStatus rs ON r.reviewStatusID = rs.reviewStatusID
	WHERE rp.reviewUserID = @reviewUserId
	AND rs.StatusName = 'NEW'
END


GO
/****** Object:  StoredProcedure [dbo].[GetProjectByProjectID]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjectByProjectID] 
	-- Add the parameters for the stored procedure here
	@projectID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
    -- Insert statements for procedure here
	SELECT P.*, S.projectStatusName, U.realName FROM Projects P
	INNER JOIN ProjectStatus S on P.projectStatusID = S.projectStatusID
	INNER JOIN Users U ON P.projectOwnerID = U.userID
	WHERE P.projectID = @projectID
END

GO
/****** Object:  StoredProcedure [dbo].[GetProjectItemByItemID]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjectItemByItemID] 
	-- Add the parameters for the stored procedure here
	@projectItemID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * FROM ProjectItems
	WHERE projectItemID = @projectItemID
END

GO
/****** Object:  StoredProcedure [dbo].[GetProjectItemsByArtifactID]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjectItemsByArtifactID] 
	-- Add the parameters for the stored procedure here
	@artifactID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT I.*, S.projectItemStatusName FROM ProjectItems I
	INNER JOIN ProjectItemStatus S on I.projectItemStatusID = S.projectItemStatusID
	WHERE I.projectArtifactID = @artifactID
END


GO
/****** Object:  StoredProcedure [dbo].[GetProjectPhaseArtifactsByPhaseId]    Script Date: 01/16/2009 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjectPhaseArtifactsByPhaseId] 
	-- Add the parameters for the stored procedure here
	@projectPhaseID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * From ProjectArtifacts WHERE projectPhaseID = @projectPhaseID
END

GO
/****** Object:  StoredProcedure [dbo].[GetProjectPhasesByProjectID]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjectPhasesByProjectID] 
	-- Add the parameters for the stored procedure here
	@projectID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * from ProjectPhases WHERE projectID = @projectID
END


GO
/****** Object:  StoredProcedure [dbo].[GetProjects]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetProjects] 
	-- Add the parameters for the stored procedure here
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT P.*, S.projectStatusName, U.realName FROM Projects P
	INNER JOIN ProjectStatus S on P.projectStatusID = S.projectStatusID
	INNER JOIN Users U ON P.projectOwnerID = U.userID
END


GO
/****** Object:  StoredProcedure [dbo].[GetReviewByReviewFileID]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewByReviewFileID] 
	-- Add the parameters for the stored procedure here
	@reviewFileID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT r.* from Reviews r
	INNER JOIN ReviewFiles rf ON rf.reviewID = r.reviewID
	WHERE rf.reviewFileID = @reviewFileID
END


GO
/****** Object:  StoredProcedure [dbo].[GetReviewCommentsByReviewFileIdAndLine]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewCommentsByReviewFileIdAndLine] 
	-- Add the parameters for the stored procedure here
	@reviewFileId int = 0, 
	@lineNumber int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	    -- Insert statements for procedure here
	SELECT rfc.*,ru.reviewUserEmail,s.severityName from ReviewFileComments rfc
	INNER JOIN Users ru on rfc.reviewUserId = ru.UserId
	INNER JOIN Severity s on s.severityID = rfc.severityID
	WHERE rfc.reviewFileId = @reviewFileId 
	AND lineNumber = @lineNumber
END




GO
/****** Object:  StoredProcedure [dbo].[GetReviewCommentsByReviewId]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewCommentsByReviewId] 
	-- Add the parameters for the stored procedure here
	@reviewID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rc.*, ru.reviewUserEmail, s.severityName from ReviewComments rc
	INNER JOIN Users ru on ru.UserId = rc.ReviewUserId
	INNER JOIN Severity s on s.severityID = rc.severityID
	where rc.reviewID = @reviewID
END



GO
/****** Object:  StoredProcedure [dbo].[GetReviewFileCommentsByReviewFileId]    Script Date: 01/16/2009 09:25:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO









-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewFileCommentsByReviewFileId] 
	-- Add the parameters for the stored procedure here
	@reviewFileId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rfc.*,ru.reviewUserEmail,s.severityName from ReviewFileComments rfc
	INNER JOIN Users ru on rfc.reviewUserId = ru.UserId
	INNER JOIN Severity s on s.severityID = rfc.severityID
	WHERE rfc.reviewFileId = @reviewFileId AND lineNumber < 0
END







GO
/****** Object:  StoredProcedure [dbo].[GetReviewFilesByReviewFileId]    Script Date: 01/16/2009 09:25:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO






-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewFilesByReviewFileId] 
	-- Add the parameters for the stored procedure here
	@ReviewFileId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rf.*, r.defectNumber, svnR.repositoryURL, svnR.repositoryKey, svnR.repositoryServerURL
	From ReviewFiles rf
	INNER JOIN Reviews r ON r.reviewID = rf.reviewID
	INNER JOIN SVNRepository svnR ON rf.repositoryID = svnR.repositoryID	
	WHERE rf.ReviewFileId = @ReviewFileId
	AND rf.hidden != 1
END





GO
/****** Object:  StoredProcedure [dbo].[GetReviewFilesByReviewId]    Script Date: 01/16/2009 09:25:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO





-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewFilesByReviewId] 
	-- Add the parameters for the stored procedure here
	@ReviewId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rf.*, r.defectNumber, svnR.repositoryURL, svnR.repositoryKey, svnR.repositoryServerURL
	From ReviewFiles rf
	INNER JOIN Reviews r ON r.reviewID = rf.reviewID
	INNER JOIN SVNRepository svnR ON rf.repositoryID = svnR.repositoryID
	WHERE rf.ReviewId = @ReviewId
	AND rf.hidden != 1
END




GO
/****** Object:  StoredProcedure [dbo].[GetReviewLogByReviewID]    Script Date: 01/16/2009 09:25:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewLogByReviewID] 
	-- Add the parameters for the stored procedure here
	@reviewID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rl.*, ru.realName,ru.reviewUserEmail from ReviewLog rl
	INNER JOIN Users ru ON rl.reviewUserID = ru.UserID
	WHERE rl.ReviewID = @reviewID
	ORDER BY rl.logTimeStamp
END



GO
/****** Object:  StoredProcedure [dbo].[GetReviewParticipantsByReviewID]    Script Date: 01/16/2009 09:25:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO







-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewParticipantsByReviewID] 
	-- Add the parameters for the stored procedure here
	@reviewID int
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT rp.*,ru.reviewUserEmail,ru.realName,ru.enableCreateMail,
		ru.enableDeltaStatusMail,ru.enableCommentMail,ru.enableJoinMail,
		ru.enableOtherReviewersMail,rs.statusName,rs.isApprovalStatus,
		rs.isParticipantStatus,rs.isClosedStatus,rs.isFinishedStatus
	from ReviewParticipants rp 
	INNER JOIN Users ru on rp.reviewUserID = ru.UserID
	INNER JOIN ReviewStatus rs on rs.reviewStatusID = rp.reviewStatusID
	WHERE rp.reviewID = @reviewID
END








GO
/****** Object:  StoredProcedure [dbo].[GetReviewsById]    Script Date: 01/16/2009 09:25:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author:		Cory Trese
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetReviewsById] 
	-- Add the parameters for the stored procedure here
	@ReviewId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT r.*,s.StatusName, s.isApprovalStatus, s.isClosedStatus, s.isFinishedStatus, 
		s.afterApprovalStatus, s.afterParticipantStatus, s.afterClosedStatus  From Reviews r
	INNER JOIN ReviewStatus s ON r.ReviewStatusId = s.ReviewStatusId
	WHERE r.ReviewId = @ReviewId
END


GO
/****** Object:  StoredProcedure [dbo].[GetRevisionLatest]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetRevisionLatest] 
		@repositoryID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT isnull(MAX(revision),0) as DatabaseRevision 
	FROM SVNLog
	WHERE repositoryID = @repositoryID
END



GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByLogID]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNLogByLogID] 
	-- Add the parameters for the stored procedure here
	@logID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT revision, author, date, defectNumber, logMessage, logXml, repositoryID FROM SVNLog WHERE logID = @logID
END




GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByRevision]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNLogByRevision] 
	-- Add the parameters for the stored procedure here
	@revision int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT revision, author, date, defectNumber, logMessage, logXml, repositoryID, logID FROM SVNLog WHERE revision = @revision
END




GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogByRevisionAndRepository]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNLogByRevisionAndRepository] 
	-- Add the parameters for the stored procedure here
	@revision int,
	@repositoryID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT revision, author, date, defectNumber, logMessage, logXml, repositoryID, logID FROM SVNLog WHERE revision = @revision AND repositoryID = @repositoryID
END




GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogEntriesByAuthorButNotDefectNumber]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO





-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================

-- var logEntries = (from logs in ViewData.DAO.SVNLog 
-- where logs.DefectNumber == ViewData.CurrentDefectNumber orderby logs.Revision descending select logs); 

CREATE PROCEDURE [dbo].[GetSVNLogEntriesByAuthorButNotDefectNumber] 
	-- Add the parameters for the stored procedure here
	@defectNumber int ,
	@author VARCHAR(255)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT svl.logID, svl.revision, svl.author, svl.defectNumber, svl.logMessage, svl.logXml, svl.date, ij.ReviewCount FROM SVNLog svl
	LEFT JOIN (
		SELECT MAX(sl.revision) as revision, COUNT(*) as ReviewCount from SVNLog sl
		INNER JOIN SVNLogRevisionReviews rr ON sl.logID = rr.logID
		GROUP BY  rr.logID
	) ij ON ij.revision = svl.revision
	WHERE svl.defectNumber != @defectNumber AND svl.author = @author
	ORDER BY svl.revision DESC
END






GO
/****** Object:  StoredProcedure [dbo].[GetSVNLogEntriesByDefectNumber]    Script Date: 01/16/2009 09:25:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO





-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================

-- var logEntries = (from logs in ViewData.DAO.SVNLog 
-- where logs.DefectNumber == ViewData.CurrentDefectNumber orderby logs.Revision descending select logs); 

CREATE PROCEDURE [dbo].[GetSVNLogEntriesByDefectNumber] 
	-- Add the parameters for the stored procedure here
	@defectNumber int 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT svl.logID, svl.Revision, svl.author, svl.defectNumber, svl.logMessage, svl.date, ij.ReviewCount FROM SVNLog svl
	LEFT JOIN (
		SELECT MAX(sl.revision) as revision, COUNT(*) as ReviewCount from SVNLog sl
		INNER JOIN SVNLogRevisionReviews rr ON sl.logID = rr.logID
		WHERE defectNumber = @defectNumber
		GROUP BY  rr.logID
	) ij ON ij.revision = svl.revision
	WHERE svl.defectNumber = @defectNumber
	ORDER BY svl.revision DESC
END





GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositories]    Script Date: 01/16/2009 09:25:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNRepositories]
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * FROM SVNRepository
END

GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositoryByID]    Script Date: 01/16/2009 09:25:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNRepositoryByID]
	-- Add the parameters for the stored procedure here
	@repositoryID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT repositoryID, repositoryURL
	FROM SVNRepository
	WHERE repositoryID = @repositoryID
END

GO
/****** Object:  StoredProcedure [dbo].[GetSVNRepositoryByURL]    Script Date: 01/16/2009 09:25:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetSVNRepositoryByURL]
	-- Add the parameters for the stored procedure here
	@repositoryURL varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT repositoryID, repositoryURL
	FROM SVNRepository
	WHERE repositoryURL = @repositoryURL
END

GO
/****** Object:  StoredProcedure [dbo].[GetUserByEmail]    Script Date: 01/16/2009 09:25:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetUserByEmail] 
	-- Add the parameters for the stored procedure here
	@reviewUserEmail varchar(255)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * FROM Users
	WHERE reviewUserEmail = @reviewUserEmail
END


GO
/****** Object:  StoredProcedure [dbo].[GetUserByUserID]    Script Date: 01/16/2009 09:25:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetUserByUserID] 
	-- Add the parameters for the stored procedure here
	@reviewUserID int 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * from Users where
	UserID = @reviewUserID
END


GO
/****** Object:  StoredProcedure [dbo].[GetUserSessionByUserID]    Script Date: 01/16/2009 09:25:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[GetUserSessionByUserID] 
	-- Add the parameters for the stored procedure here
	@reviewUserID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	select sessionVarName, sessionVarValue 
	FROM UserSessions
	WHERE reviewUserID = @reviewUserID
END


GO
/****** Object:  StoredProcedure [dbo].[InsertReviewParticipant]    Script Date: 01/16/2009 09:25:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertReviewParticipant] 
	-- Add the parameters for the stored procedure here
	@reviewId int, 
	@reviewUserId int,
	@isReviewer bit
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT into ReviewParticipants (reviewID, reviewUserID, participantIsReviewer ) VALUES (@reviewId, @reviewUserId, @isReviewer )
END


GO
/****** Object:  StoredProcedure [dbo].[InsertReviewUserSessionVar]    Script Date: 01/16/2009 09:25:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertReviewUserSessionVar]
	-- Add the parameters for the stored procedure here
	@reviewUserID int, @sessionVarName VARCHAR(42), @sessionVarValue VARCHAR(8000)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE FROM UserSessions WHERE sessionVarName = @sessionVarName

	INSERT INTO UserSessions (reviewUserID, sessionVarName, sessionVarValue) VALUES (@reviewUserID, @sessionVarName, @sessionVarValue )
END


GO
/****** Object:  StoredProcedure [dbo].[InsertSVNLog]    Script Date: 01/16/2009 09:25:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertSVNLog] 
	-- Add the parameters for the stored procedure here
	@revision int, 
	@author VARCHAR(255),
	@date DateTime,
	@logMessage VARCHAR(255),
	@logXml VARCHAR(MAX),
	@defectNumber int,
	@repositoryID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO SVNLog (revision, author, date, logMessage, logXml, defectNumber, repositoryID ) 
	VALUES (@revision, @author, @date, @logMessage, @logXml, @defectNumber, @repositoryID)
END


GO
/****** Object:  StoredProcedure [dbo].[InsertSVNLogRevisionReview]    Script Date: 01/16/2009 09:25:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertSVNLogRevisionReview] 
	-- Add the parameters for the stored procedure here
	@logID int = 0, 
	@reviewID int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	--DECLARE @logID int;

    -- Insert statements for procedure here
	--SELECT @logID = logID
	--FROM SVNLog
	--WHERE revision = @revision;

	 INSERT INTO SVNLogRevisionReviews (logID, reviewID) VALUES (@logID, @reviewID);
END



GO
/****** Object:  StoredProcedure [dbo].[InsertUser]    Script Date: 01/16/2009 09:25:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertUser] 
	-- Add the parameters for the stored procedure here
	@userEmail varchar(255), 
	@password varchar(255),
	@name varchar(255),
	@svn_uid varchar(255)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO Users ( reviewUserEmail, cryptedpassword, realName, disableMail, disableUser, SVNAuthor, enableCreateMail, enableDeltaStatusMail, 
		enableCommentMail, enableJoinMail, enableOtherReviewersMail )  VALUES ( @userEmail, @password, @name, 'false', 'false', @svn_uid, 'false', 'false', 
		'false', 'false', 'false' )
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateProjectItem]    Script Date: 01/16/2009 09:25:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateProjectItem] 
	-- Add the parameters for the stored procedure here
	@projectItemID int, 
	@title varchar(MAX),
	@URL varchar(MAX)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE ProjectItems SET URL = @URL, projectItemTitle = @title
	WHERE projectItemID = @projectItemID
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewDetailsByReviewID]    Script Date: 01/16/2009 09:25:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateReviewDetailsByReviewID] 
	-- Add the parameters for the stored procedure here
	@reviewID int , 
	@title VARCHAR(255),
	@description VARCHAR(MAX)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE Reviews SET title=@title, description=@description
	WHERE reviewID = @reviewID
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewFileHideByReviewFileId]    Script Date: 01/16/2009 09:25:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateReviewFileHideByReviewFileId] 
	-- Add the parameters for the stored procedure here
	@reviewFileID int, 
	@hidden bit
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE ReviewFiles SET hidden=@hidden WHERE reviewFileID =  @reviewFileID
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewParticipantStatus]    Script Date: 01/16/2009 09:25:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateReviewParticipantStatus] 
	-- Add the parameters for the stored procedure here
	@reviewUserID int, 
	@reviewID int,
	@reviewStatusID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE ReviewParticipants SET reviewStatusID = @reviewStatusID
	WHERE reviewUserID = @reviewUserID AND reviewID = @reviewID
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewParticipantVisit]    Script Date: 01/16/2009 09:25:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateReviewParticipantVisit] 
	-- Add the parameters for the stored procedure here
	@reviewID int, 
	@reviewUserID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE ReviewParticipants SET visitTimeStamp = GETDATE()
	WHERE reviewID = @reviewID
	AND reviewUserID = @reviewUserID
END

GO
/****** Object:  StoredProcedure [dbo].[UpdateReviewStatusByReviewID]    Script Date: 01/16/2009 09:25:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Name
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[UpdateReviewStatusByReviewID] 
	-- Add the parameters for the stored procedure here
	@reviewID int,
	@reviewStatusID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	UPDATE Reviews SET reviewStatusID = @reviewStatusID
	WHERE reviewId = @reviewID
END


